package com.rescue.controller.user;

import com.rescue.forum.dto.AcceptRescueDTO;
import com.rescue.forum.dto.CommonRescueDTO;
import com.rescue.forum.dto.FastRescueDTO;
import com.rescue.forum.dto.RecordPageQueryDTO;
import com.rescue.result.PageResult;
import com.rescue.result.Result;
import com.rescue.service.RescueRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/user/rescueRecord")
@RestController("RescueRecordController")
@Api(tags = "救援记录相关接口")
@Slf4j
public class RescueRecordController {
    @Autowired
    private RescueRecordService rescueRecordService;
    /**
     * 一键救援接口
     * @param fastRescueDTO
     * @return
     */
    @ApiOperation("一键救援接口")
    @PostMapping("/fastRescue")
    private Result fastRescue(@RequestBody FastRescueDTO fastRescueDTO){
        log.info("一键救援接口{}",fastRescueDTO);
        rescueRecordService.fastRescue(fastRescueDTO);
        return Result.success();
    }

    /**
     * 普通救援接口
     * @param commonRescueDTO
     * @return
     */
    @ApiOperation("普通救援接口")
    @PostMapping("/commonRescue")
    private Result commonRescue(@RequestBody CommonRescueDTO commonRescueDTO){
        log.info("不同救援接口{}",commonRescueDTO);
        rescueRecordService.commonRescue(commonRescueDTO);
        return Result.success();
    }

    /**
     * 获取救援记录
     * @param recordPageQueryDTO
     * @return
     */
    @ApiOperation("获取救援记录")
    @GetMapping("/getRecord")
    private Result<PageResult> getRecord(RecordPageQueryDTO recordPageQueryDTO){
        log.info("救援记录分页查询{}",recordPageQueryDTO);
        PageResult pageResult = rescueRecordService.PageQuery(recordPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 接收救援接口
     * @param acceptRescueDTO
     * @return
     */
    @ApiOperation("接收救援记录")
    @PostMapping("/acceptRescue")
    private Result acceptRescue(@RequestBody AcceptRescueDTO acceptRescueDTO){
        log.info("接收救援记录{}",acceptRescueDTO);
        rescueRecordService.acceptRescue(acceptRescueDTO);
        return Result.success();
    }

    /**
     * 完成救援
     * @param rescueRecordId
     * @return
     */
    @ApiOperation("完成救援记录")
    @PostMapping("/completeRescue")
    private Result completeRescue(Integer rescueRecordId){
        log.info("完成了一个救援{}",rescueRecordId);
        rescueRecordService.completeRescue(rescueRecordId);
        return Result.success();
    }
    /**
     * 救援人取消救援
     */
    @ApiOperation("取消救援")
    @PostMapping("/callOffRescue")
    private Result callOffRescue(Integer rescueRecordId){
        log.info("取消了一个救援{}",rescueRecordId);
        rescueRecordService.callOffRescue(rescueRecordId);
        return Result.success();
    }


}
